package enums.learn;

import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.reader.ObjectReader;
import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.Type;
import java.math.BigDecimal;

@Slf4j
public class MyLongReader implements ObjectReader<Long> {
    static final MyLongReader INSTANCE = new MyLongReader();
    @Override
    public Long readObject(JSONReader jsonReader, Type type, Object fieldName, long l) {
//        Number number=jsonReader.getNumber();
//        System.out.println(number);
  //      log.info("jsonReader.readInt64() = {}",jsonReader.readInt64());
//        log.info("jsonReader.readString() = {}",jsonReader.readString());
//        log.info("type = {}",type);
//        log.info("fieldName= {}",fieldName);

        System.out.println("jsonReader.readString() =" +jsonReader.readString());
        System.out.println(jsonReader.info());
        System.out.println("jsonReader.readObject() =" +jsonReader.readObject());
        System.out.println(jsonReader.nextIfNull());
        //jsonReader.next();
        System.out.println(jsonReader.isEnd());
        System.out.println("jsonReader.readObject() =" +jsonReader.readObject());
        System.out.println(jsonReader.readAny()+"abc");

        while(!jsonReader.isEnd()){
            log.info("jsonReader.current() =",jsonReader.current());
            System.out.println(jsonReader.getOffset());
            System.out.println(jsonReader.readAny());
            jsonReader.next();
        }

        if(jsonReader.nextIfNull()){
            System.out.println("in null");
            return null;
        }
        Long result=jsonReader.readInt64();

        log.info("jsonReader.readInt64() = {}",result);
        //log.info("jsonReader.readString() = {}",jsonReader.readString());
        log.info("type = {}",type);
        log.info("fieldName= {}",fieldName);

        System.out.println(type);
        System.out.println(fieldName);
        return 20L;
    }
}
